package com.github.ppamorim.sample.cult;

import com.github.ppamorim.cult.CultView;
import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import ohos.agp.components.Attr;
import ohos.agp.components.AttrSet;
import ohos.agp.utils.Color;
import ohos.app.Context;
import org.junit.Test;
import org.junit.runner.manipulation.Ordering;

import java.util.Optional;

import static org.junit.Assert.*;

public class ExampleOhosTest {

    Context context = MainAbility.getAppContext();
    @Test
    public void testBundleName() {
        final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
        assertEquals("com.github.ppamorim.sample.cult", actualBundleName);
    }


    @Test
    public void testContext(){
        try {
            assertTrue(context == null);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    @Test
    public void testRoundRadius(){
        CultView cultView = new CultView(context, new AttrSet() {
            @Override
            public Optional<String> getStyle() {
                return Optional.empty();
            }

            @Override
            public int getLength() {
                return 0;
            }

            @Override
            public Optional<Attr> getAttr(int i) {
                return Optional.empty();
            }

            @Override
            public Optional<Attr> getAttr(String s) {
                return Optional.empty();
            }
        });
        cultView.setRoundRadius(100);
        int radius = cultView.getRoundRadius();
        assertTrue(radius == 100);
    }

    @Test
    public void testSetRippleColor(){
        CultView cultView = new CultView(context, new AttrSet() {
            @Override
            public Optional<String> getStyle() {
                return Optional.empty();
            }

            @Override
            public int getLength() {
                return 0;
            }

            @Override
            public Optional<Attr> getAttr(int i) {
                return Optional.empty();
            }

            @Override
            public Optional<Attr> getAttr(String s) {
                return Optional.empty();
            }
        });
        cultView.setRippleColor(new Color(1000));
        Color color = cultView.getRippleColor();
        assertNotNull(color);
    }

    @Test
    public void testSetRippleDuration(){
        CultView cultView = new CultView(context, new AttrSet() {
            @Override
            public Optional<String> getStyle() {
                return Optional.empty();
            }

            @Override
            public int getLength() {
                return 0;
            }

            @Override
            public Optional<Attr> getAttr(int i) {
                return Optional.empty();
            }

            @Override
            public Optional<Attr> getAttr(String s) {
                return Optional.empty();
            }
        });
        cultView.setRippleDuration(100);
        int duraion = cultView.getRippleDuration();
        assertTrue(duraion == 100);
    }

    @Test
    public void testSetRippleAlpha(){
        CultView cultView = new CultView(context, new AttrSet() {
            @Override
            public Optional<String> getStyle() {
                return Optional.empty();
            }

            @Override
            public int getLength() {
                return 0;
            }

            @Override
            public Optional<Attr> getAttr(int i) {
                return Optional.empty();
            }

            @Override
            public Optional<Attr> getAttr(String s) {
                return Optional.empty();
            }
        });
        cultView.setRippleAlpha(100);
        int alph = cultView.getRippleAlpha();
        assertTrue(alph == 100);
    }

    @Test
    public void testsetRipple(){
        CultView cultView = new CultView(context, new AttrSet() {
            @Override
            public Optional<String> getStyle() {
                return Optional.empty();
            }

            @Override
            public int getLength() {
                return 0;
            }

            @Override
            public Optional<Attr> getAttr(int i) {
                return Optional.empty();
            }

            @Override
            public Optional<Attr> getAttr(String s) {
                return Optional.empty();
            }
        });
        cultView.setRipple(100);
        Color color = cultView.getRippleColor();
        assertNotNull(color);
    }

}